package com.lzq.leetcode.lanqiao;

import java.util.Scanner;
import java.util.Stack;

public class s6 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] ids = new int[n];
        for (int i=0; i<n; i++) {
            ids[i] = scanner.nextInt();
        }
        boolean[] visited = new boolean[n];
        int counter = 0;
        //
        for (int i=0; i<n; i++) {
            int p = i;
            if (!visited[p])    ++counter;
            while (!visited[p]) {
                visited[p] = true;
                p = ids[p] - 1;
            }
        }
        System.out.println(counter);
    }

}
